<?php
/**
	***** ABSTRACT *****
		
		File name:			dbCon_config.html
		Version:			1.0
		Initial author:		Haitao Huang 
		Create date:		2nd Apr 2016
		Lastest edit:		3rd Apr 2016
		Description:		this PHP file is the model of database connection.
							You can invoke the functions from this file in other modules.

**/
	include "dbCon_config.php";
	
	function dbConnect_init(){
		$sqlCon = mysqli_connect(HOST, USERNAME, PASSWORD, DBNAME, PORT);
		
		if ($conn->connect_error) {
			die("Connection failed: " . $conn->connect_error);
		}elseif($sqlCon){
			echo "<p>success!</p>";
		}else{
			echo "<p>fail!</p>";
		}

		echo "<p>mysql database version: ".mysqli_get_server_version($sqlCon)."</p>";
		$version = mysqli_fetch_assoc(mysqli_query($sqlCon, "select version();"));
		echo "result of version query: ".$version["version()"]."</br>";

		$tbList = mysqli_fetch_assoc(mysqli_query($sqlCon, "show tables;"));
		echo "table list of database xfwang: ".$tbList["Tables_in_xfwang"];
		
		$sql = "select * from test order by id desc;";
		$sqlQuery = mysqli_query($sqlCon, $sql);

		echo "RESULT:</br>";

		while ($sqlResult = mysqli_fetch_assoc($sqlQuery)) {
			print_r($sqlResult);
		}
		printf("</br>%d row result return", mysqli_num_rows($sqlQuery));

		mysqli_free_result($sqlQuery);
		mysqli_close($sqlCon);
	}
	
	dbConnect_init();
?>